{extend name="$base" /}
{block name="resources"}
<link rel="stylesheet" type="text/css" href="ADMIN_CSS/defau.css">
<style type="text/css">
	.unit{position: relative;top: -1px;}
</style>
{/block}
{block name="main"}
<div class="set-style">
	<dl>
		<dt>历史申请:</dt>
		<dd>
			<table class="table-class">
				<colgroup>
					<col style="width: 33%;">
					<col style="width: 33%;">
					<col style="width: 33%;">
				</colgroup>
				<thead>
				<tr>
					<th>申请时间</th>
					<th>申请地区</th>
					<th>申请品类</th>
				</tr>
				</thead>
				<tbody>
				{if condition="!empty($apply_list)"}
				{volist name="apply_list" id="apply"}
				<tr align="center">
					<td>{:date('Y-m-d H:i:s', $apply.apply_time)}</td>
					<td>{$apply.address_arr.province_name}{$apply.address_arr.city_name}{$apply.address_arr.district_name}</td>
					<td>{volist name="$apply.category_arr" id="category"}{$category.category_name}&nbsp;&nbsp;{/volist}</td>
				</tr>
				{/volist}
				{else/}
				<tr align="center">
					<td colspan="3">暂无历史申请</td>
				</tr>
				{/if}
				</tbody>
			</table>
		</dd>
	</dl>
	<dl>
		<dt>当前申请:</dt>
		<dd>
			<table class="table-class">
				<colgroup>
					<col style="width: 33%;">
					<col style="width: 33%;">
					<col style="width: 33%;">
				</colgroup>
				<thead>
				<tr>
					<th>申请时间</th>
					<th>申请地区</th>
					<th>申请品类</th>
				</tr>
				</thead>
				<tbody>
				<tr align="center">
					<td>{:date('Y-m-d H:i:s', $apply_info.apply_time)}</td>
					<td>{$apply_info.address_arr.province_name}{$apply_info.address_arr.city_name}{$apply_info.address_arr.district_name}</td>
					<td>{volist name="$apply_info.category_arr" id="category"}{$category.category_name}&nbsp;&nbsp;{/volist}</td>
				</tr>
				</tbody>
			</table>
		</dd>
	</dl>
	<dl>
		<dt>操作记录:</dt>
		<dd>
			<table class="table-class">
				<colgroup>
					<col style="width: 15%;">
					<col style="width: 15%;">
					<col style="width: 25%;">
					<col style="width: 45%;">
				</colgroup>
				<thead>
				<tr>
					<th>操作人</th>
					<th>操作类型</th>
					<th>操作时间</th>
					<th>其他信息</th>
				</tr>
				</thead>
				<tbody>
				{volist name="action_list" id="action"}
				<tr align="center">
					<td>{$action.user_name}</td>
					<td>{$action.action_title}</td>
					<td>{:date('Y-m-d H:i:s', $action.action_time)}</td>
					<td>
						{if condition="!empty($action.remark)"}
						<p>备注：{$action.remark}</p>
						{/if}
						{if condition="$action.action_name == 'check_pass' && !empty($action.other_info.give_money)"}
						<p>赠送金额：{$action.other_info.give_money}元</p>
						{/if}
					</td>
				</tr>
				{/volist}
				</tbody>
			</table>
		</dd>
	</dl>
	{if condition="$apply_info.audit_status eq 'check_pass'"}
	<dl>
		<dt>确认结果：</dt>
		<dd>
			<label for="navigationtype1" class="radio inline normal">
				<i class="radio-common selected">
					<input type="radio" value="confirm_pass" name="audit_res" id="navigationtype1"  checked/>
				</i>
				<span>通过</span>
			</label>
			<label for="navigationtype2" class="radio inline normal">
				<i class="radio-common">
					<input type="radio" value="confirm_refuse" name="audit_res" id="navigationtype2"/>
				</i>
				<span>驳回</span>
			</label>
		</dd>
	</dl>
	<dl class="audit_res confirm_refuse" style="display:none;">
		<dt>驳回理由：</dt>
		<dd>
			<textarea class="textarea-common" id="remark"></textarea>
		</dd>
	</dl>
	<dl>
		<dt></dt>
		<dd>
			<button class="btn-common btn-big" onclick="auditSubmit();">提交</button>
			<button class="btn-common btn-big" onclick="backPage();">返回</button>
		</dd>
	</dl>
	<input type="hidden" id="apply_id" value="{$apply_info.apply_id}"/>
	{else/}
	<dl>
		<dt></dt>
		<dd>
			<button class="btn-common btn-big" onclick="backPage();">返回</button>
		</dd>
	</dl>
	{/if}
</div>

<script>
    //提交审核结果
    function auditSubmit(){
        var apply_id = $("#apply_id").val();
        var audit_res = $("input[name='audit_res']:checked").val();
        var give_money = 0.00;
        var remark = '';
        if(audit_res === 'confirm_pass'){
            confirmPass(apply_id, give_money);
        }else{
            remark = $("#remark").val();
            if(!remark){
                showTip('请输入驳回理由', 'warning');
                return false;
            }
            confirmRefuse(apply_id, remark);
        }
    }

    //确认通过
    function confirmPass(apply_id){
        $.ajax({
            type:"post",
            url:"{:__URL('__URL__/nsfx/ADMIN_MODULE/regionagent/confirmpass')}",
            data:{
                'apply_id':apply_id
            },
            success:function (data) {
                if (data["code"] > 0) {
                    showMessage('success', data["message"],document.referrer);
                }else{
                    showMessage('error', data["message"]);
                }
            }
        });
    }

    //确认驳回
    function confirmRefuse(apply_id, remark){
        $.ajax({
            type:"post",
            url:"{:__URL('__URL__/nsfx/ADMIN_MODULE/regionagent/confirmrefuse')}",
            data:{
                'apply_id':apply_id,
                'remark':remark
            },
            success:function (data) {
                if (data["code"] > 0) {
                    showMessage('success', data["message"],document.referrer);
                }else{
                    showMessage('error', data["message"]);
                }
            }
        });
    }

    function backPage(){
        window.location.href = document.referrer;
    }

    //切换审核结果
    $("input[name='audit_res']").click(function(){
        var audit_res = $(this).val();
        $(".audit_res").hide();
        $(".audit_res." + audit_res).show();
    })
</script>
{/block}